package mumethod;

import java.util.List;

import muobject.PhysicalSimpleSummary;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class PhysicalSimpleReportDataSource implements JRDataSource{
	private List<PhysicalSimpleSummary> datas = null ;
	private int loop = -1 ; 
	
	public PhysicalSimpleReportDataSource(List<PhysicalSimpleSummary> data){
		this.datas = data;
	}
	
	public Object getFieldValue(JRField field) throws JRException {
		PhysicalSimpleSummary temp = (PhysicalSimpleSummary)this.datas.get(loop);
		Object rs = "" ;
		if("year".equals(field.getName())){  
			rs = temp.getYear();   
		}else if("grade".equals(field.getName())){
			rs = temp.getGrade();
		}else if("sclass".equals(field.getName())){
			rs = temp.getSclass();
		}else if("stno".equals(field.getName())){
			rs = temp.getStno();
		}else if("classno".equals(field.getName())){
			rs = temp.getClassno();
		}else if("ename".equals(field.getName())){
			rs = temp.getEname();
		}else if("cname".equals(field.getName())){
			rs = temp.getCname();
		}else if("sex".equals(field.getName())){
			rs = temp.getSex();
		}else if("age".equals(field.getName())){
			rs = temp.getAge();
		}else if("testdate".equals(field.getName())){
			rs = temp.getTestdate();
		}else if("hwscorw".equals(field.getName())){
			rs = temp.getHwscorw();
		}else if("gripacore".equals(field.getName())){
			rs = temp.getGripscore();
		}else if("jumpscore".equals(field.getName())){
			rs = temp.getJumpscore();
		}else if("situpscore".equals(field.getName())){
			rs = temp.getSitupscore();
		}else if("vcapacityscore".equals(field.getName())){
			rs = temp.getVcapacityscore();
		}else if("run69score".equals(field.getName())){
			rs = temp.getRun69score();
		}else if("run15score".equals(field.getName())){
			rs = temp.getRun15score();
		}else if("totalscore".equals(field.getName())){
			rs = temp.getTotalscore();
		}else if("level".equals(field.getName())){
			rs = temp.getLevel();
		}
		
		temp = null ;  
		return rs;
	}
	
	public boolean next() throws JRException {
		loop ++ ;
		if(loop >= datas.size()){
			return false;
		}
		else{   
			return true ;
		}
	}
	
	public void finalized(){
		datas = null ;  
	}
}
